﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ProjectNocturnalFool
{
    /// <summary>
    /// Represents one space on the Gameboard inside the TileSet tiles.
    /// Contains information about multiple TileImages
    /// </summary>
    class Tile
    {
        public List<int> baseTileImages = new List<int>();
        public List<int> heightTileImages = new List<int>();

        public bool mouseSelected { get; set; }
        public bool availableSelection { get; set; }
        public bool inAreaOfEffect { get; set; }


        public int terrainCost;

        //movement temp variable
        public int currentMoveCost { get; set; }



        public int tileImageID
        {
            get { return baseTileImages.Count > 0 ? baseTileImages[0] : 0; }
            set
            {
                if (baseTileImages.Count > 0)
                    baseTileImages[0] = value;
                else
                    AddBaseTileImage(value);

                if (value == 0)
                {
                    terrainCost = Constants.flatTerrainCost;
                }
                else
                {
                    terrainCost = Constants.roughTerrainCost;
                }
                
            }
        }

        public void AddBaseTileImage(int tileImageID)
        {
            baseTileImages.Add(tileImageID);
        }

        public void AddHeightTileImage(int tileImageID)
        {
            heightTileImages.Add(tileImageID);
        }

        /// <summary>
        /// Returns the number of height tile images
        /// </summary>
        /// <returns></returns>
        public int getHeight() {
            if (heightTileImages == null)
                return 0;

            return heightTileImages.Count;
        }

        


        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="tileImageID"></param>
        public Tile(int tImageID)
        {
            tileImageID = tImageID;
            if(tileImageID==0){terrainCost = Constants.flatTerrainCost;}
            else { terrainCost = Constants.mediumTerrainCost; }

        }


        public void Update(GameTime gameTime) {
            if (mouseSelected&&availableSelection) {
                DebugMgr.Instance.addDebug("MoveCost: " + currentMoveCost, 4);
            }      
        }
    }
}
